#ifndef ENTITY_H_
#define ENTITY_H_

#include <iostream>
#include "json.hpp"
using json = nlohmann::json;
using namespace std;
class User
{
public:
    User()
    {
    }
    User(string &username, string &password)
    {
        this->username = username;
        this->password = password;
       
    }
    string getUsername()
    {
        return username;
    }
    void setUsername(const string &name)
    {
        username = name;
    }
    string getPassword()
    {
        return password;
    }
    void setPassword(const string &pass)
    {
        password = pass;
    }
    // 从JSON对象转换为类对象
    void from_json(const json &j)
    {
        username = j.at("username").get<string>();
        password = j.at("password").get<string>();
    }
    // 将对象转换为 JSON 对象
    json toJSON() const
    {
        return json{
            {"uid", uid},
            {"username", username},
            {"password", password}// 注意：email 可能是 null
        };
    }
    void setUid(const string &Uid)
    {
        uid = Uid;
    }
    string getUid()
    {
        return uid;
    }

private:
    string username = "";
    string password = "";

public:
    string uid;
};

// 用户信息
class UserInformation
{
public:
    string userid;
    string sex;
    string age;
    string birthday;
    string name;
    string headPortrait;
public:
    UserInformation() {}
    UserInformation(const string &userid, string sex, const string &age, const string &birthday, const string &name, const string &headPortrait)
    {
        this->userid = userid;
        this->sex = sex;
        this->age = age;
        this->birthday = birthday;
        this->name = name;
        this->headPortrait = headPortrait;
    }
    // // 从JSON对象转换为类对象
    // void from_json(const json &j)
    // {
    //     username = j.at("username").get<string>();
    //     password = j.at("password").get<string>();
    // }
    // 将对象转换为 JSON 对象
    json toJSON() const
    {
        return json{
            {"userid", userid},
            {"sex", sex},
            {"age", age},
            {"birthday", birthday},
            {"name", name},
            {"headPortrait", headPortrait}
        };
    }
};

#endif // ENTITY_H_